#pragma once

#ifndef UTIL_H
#define UTIL_H

#include <math.h>
#define GRA_PI  180/M_PI
#define DGR_PI	M_PI/180

#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif


double dir_angle(double x,double y)
{
	double dist = sqrt(x*x+y*y);
	double angle = M_PI/2-asin(y/dist);
	if(x<0){
		angle = M_PI*2 - angle;
	}
	return angle;
}

double angle_0_360(double ang)
{
	while(ang<0){
		ang+=M_PI*2;
	}
	while(ang>=M_PI*2){
		ang-=M_PI*2;
	}
	return ang;
}

#endif